package lawyer.Service;

import common.model.Appeal;
import common.model.Lawyer;
import lawyer.repository.LawyerRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class LawyerService {

    @Autowired
    private LawyerRepository lawyerRepository;

    public Lawyer updateProfile(Lawyer lawyer) {
        return lawyerRepository.save(lawyer);
    }

    public Lawyer getProfile(Long id) {
        return lawyerRepository.findById(id).orElseThrow(() -> new RuntimeException("Lawyer not found"));
    }

    public void setPreferences(List<String> preferences, Long lawyerId) {
        Lawyer lawyer = lawyerRepository.findById(lawyerId).orElseThrow(() -> new RuntimeException("Lawyer not found"));
        lawyer.setPreferences(preferences);
        lawyerRepository.save(lawyer);
    }

    public void appealFreeze(Appeal appeal) {
        // 实现冻结申诉逻辑
    }
}